package com.csun.cmny.provider.controller;

import com.csun.cmny.core.support.BaseController;
import com.csun.cmny.provider.model.dto.RechargeDto;
import com.csun.cmny.provider.model.dto.RechargeQueryDto;
import com.csun.cmny.provider.model.vo.RechargeVO;
import com.csun.cmny.provider.resolver.CmnyMessageSource;
import com.csun.cmny.provider.service.OmcRechargeRecordService;
import com.csun.cmny.util.wrapper.WrapMapper;
import com.csun.cmny.util.wrapper.Wrapper;
import com.github.pagehelper.PageInfo;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "/rechargeRecord", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class OmcRechargeRecordController extends BaseController {

    @Resource
    private OmcRechargeRecordService omcRechargeRecordService;
    @Resource
    private CmnyMessageSource cmnyMessageSource;

    /**
     * 充值记录-充值
     *
     * @param rechargeDto
     * @return the wrapper
     */
    @RequestMapping(value = "/recharge", method = RequestMethod.POST)
    public Wrapper recharge(@RequestBody RechargeDto rechargeDto) {
        int i = omcRechargeRecordService.add(rechargeDto,getLoginAuthDto());
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),i);
    }

    /**
     * 充值记录-分页查询
     *
     * @param rechargeQueryDto
     * @return the wrapper
     */
    @RequestMapping(value = "/listPage", method = RequestMethod.POST)
    public Wrapper listPage(@RequestBody RechargeQueryDto rechargeQueryDto) {
        PageInfo<RechargeVO> rechargeVOPageInfo = omcRechargeRecordService.listPage(rechargeQueryDto);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),rechargeVOPageInfo);
    }


}
